package org.example;

import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.*;

import java.util.stream.Stream;


/**
 * @author starsea
 * @date 2024-02-16 15:32
 */
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class JunitTest {
    public static Stream<Arguments> Generate() {
        return Stream.of(Arguments.arguments("王五",12),Arguments.arguments("李四",22)

        );
    }

    //单参数
    //多参数
//多参数
//通过测试方法生成测试
    @ParameterizedTest
    @MethodSource("Generate")
    void  Test07(String name,int age)
    {
        System.out.println("接收的参数是"+"name:"+name+"age:"+age);
    }
    @Order(2)
    @Test
    public   void test01()
    {
        System.out.println("++++测试1++++++++++");
    }
    @Order(1)
    @Test
    public   void test02()
    {
        System.out.println("++++测试2++++++++++");
    }
    @BeforeAll
    public static void start()
    {
        System.out.println("++++++++++++测试开始++++++++++++++");
    }
    @AfterAll
    public static void end()
    {
        System.out.println("+++++++++++++测试结束+++++++++++++");
    }
    @BeforeEach
    void startv1()
    {
        System.out.println("++++++++开始执行测试用例++++++++++++");
    }
    @AfterEach
    void endv1()
    {
        System.out.println("++++++++执行测试用例结束++++++++++++");
    }
    @ParameterizedTest
    @ValueSource(ints={1,2,3,4,5,6})
    void test03(int x)
    {
        System.out.println("接收的参数是"+x);
    }
    @ParameterizedTest
    @CsvSource("'张三',18")
    void test04(String name,int age)
    {
        System.out.println("接收的参数是"+"name:"+name+"age:"+age);
    }
    @ParameterizedTest
    @CsvFileSource(resources= "test06.csv")
    public void test06(String name, int age)
    {
        System.out.println("接收的参数是"+"name:"+name+"age:"+age);
    }
    @Test
    void test07()
    {

        int x=10;
        int y=20;
        //断言相等
       // Assertions.assertEquals(x,y);
        //断言不相等
        Assertions.assertNotEquals(x,y);
        //断言为空

        Assertions.assertNull(null);
        //断言不为空
        String s1="qqqqq";
        Assertions.assertNotNull(s1);

    }

}
